// $Id: rtp.h 101 2011-10-21 15:07:40Z cedric.shih@gmail.com $
/*
 * Copyright 2011 Cedric Shih (cedric dot shih at gmail dot com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef RTP_H_
#define RTP_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>

#define IP_HEADER_MAX 24
#define TCP_HEADER_MAX 28
#define UDP_HEADER_MAX 8

#define MTU 1500

#define NIORTP_VIDEO_CLOCK 90000

struct timeval;

u_int32_t niortp_timeval_to_timestamp(const struct timeval *tv);

int niortp_timeval_diff(const struct timeval *t1,
		const struct timeval *t2, struct timeval *td);

struct niortp_header {
	u_int8_t a;
	u_int8_t b;
        u_int16_t seq;              /* sequence number */
        u_int32_t ts;               /* timestamp */
        u_int32_t ssrc;             /* synchronization source */
};

struct niortp_slice {
	size_t offset;
	size_t len;
};

struct niortp_jpeg_header {
        u_int32_t tspec_off;
        u_int8_t type;            /* id of jpeg decoder params */
        u_int8_t q;               /* quantization factor (or table id) */
        u_int8_t width;           /* frame width in 8 pixel blocks */
        u_int8_t height;          /* frame height in 8 pixel blocks */
};

struct niortp_jpeg_qtable {
        u_int8_t  mbz;
        u_int8_t  precision;
        u_int8_t length[2];
};

#ifdef __cplusplus
}
#endif

#endif /* RTP_H_ */
